package com.sky.controller.admin;


import com.sky.dto.OrdersPageQueryDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.admin.AdminOrderService;
import com.sky.vo.OrderStatisticsVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ExecutionException;
//test
@RestController("adminOrderController")
@RequestMapping("/admin/order")
@Api(tags = "商家订单接口")
public class AdminOrderController {

    @Autowired
    private AdminOrderService orderService;

    @GetMapping("/conditionSearch")
    @ApiOperation("分页条件条件查询订单信息")
    public Result<PageResult> conditionSearch(OrdersPageQueryDTO dto){
        return orderService.conditionSearch(dto);
    }


    /**
     * 各个状态的订单数量统计
     *
     * @return
     */
    @GetMapping("/statistics")
    @ApiOperation("各个状态的订单数量统计")
    public Result<OrderStatisticsVO> statistics() throws ExecutionException, InterruptedException {
        OrderStatisticsVO orderStatisticsVO = orderService.statistics();
        return Result.success(orderStatisticsVO);
    }
}
